package com.zheng.study.company.entity;

import org.springframework.core.annotation.Order;

import javax.persistence.*;
import java.util.Set;

/**
 * 岗位
 * ============================================================================
 * author : dzw
 * createDate:  2018/8/24 。
 * ============================================================================
 */
//@Entity
//@Table(name = "sys_post")
public class Post extends CompanyEntity {
	private static final long serialVersionUID = 542684519963533013L;

	/**
	 * 岗位代码
	 */
	private String code;
	/**
	 * 描述
	 */
	private String description;
	/**
	 * 包含此岗位的部门
	 */
	private Set<Department> departmentSet;
	/**
	 * 职权
	 */
	private Set<Power> powerSet;

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@Column(length = 4000)
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@ManyToMany(cascade = {CascadeType.ALL}, fetch = FetchType.LAZY, mappedBy = "postSet")
	@OrderBy("name asc")
	public Set<Department> getDepartmentSet() {
		return departmentSet;
	}

	public void setDepartmentSet(Set<Department> departmentSet) {
		this.departmentSet = departmentSet;
	}

	@OneToMany(mappedBy = "post", fetch = FetchType.LAZY)
	@OrderBy("name asc")
	public Set<Power> getPowerSet() {
		return powerSet;
	}

	public void setPowerSet(Set<Power> powerSet) {
		this.powerSet = powerSet;
	}
}
